package com.jk.lesson4;

import com.jk.bean.Dish;
import com.jk.bean.DishType;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * Created by Auser on 2016/12/12.
 */
public class GroupTest {
    private static List<Dish> menus = MenuTest.menu;
    public static void main(String[] args) {
        groupby_test();
    }

    private static void groupby_test(){
        System.out.println(menus.size());
        DishType t = menus.get(1).getType();
        Map<DishType, List<Dish>> gr = menus.stream().collect(Collectors.groupingBy(o -> o.getType()));
        for(DishType type : gr.keySet()){
            List<Dish> dishList = gr.get(type);
            System.out.println(type + "=====>" + dishList.size());
        }
    }
}
